package by.cooker.chat.gui;

import javax.swing.JTextPane;
import javax.swing.text.BadLocationException;
import javax.swing.text.Document;
import javax.swing.text.SimpleAttributeSet;

/**
 * @author cooker
 */
public class MessagesArea extends JTextPane
{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	/**
	 * Append text to messages area.
	 * 
	 * @param text
	 *            text of message.
	 * @param sas
	 *            text attributes.
	 */
	public void appendText(String text, SimpleAttributeSet sas)
	{
		try
		{
			Document document = getDocument();
			document.insertString(document.getLength(), text, sas);
			setCaretPosition(document.getLength());
		} catch (BadLocationException e)
		{
			e.printStackTrace();
		}
	}
}
